<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta borderStyle="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title></title>
    <link type="text/css" th:href="@{/static/admin/css/evaluate.css}" rel="stylesheet"/>
    <!--  Echarts Js-->
    <script type="text/javascript" th:src="@{/static/admin/js/echarts.min.js}"></script>
    <th:block th:include="include :: header('评价结果汇总（月度）')"/>
    <th:block th:include="include :: footer"/>

    <style>
        .layui-table-header, .layui-table-header th {
            background-color: #0d9489 !important;
            color: #fff;
        }

        .departmentBg .layui-table-cell {
            padding: 0 5px;
            height: auto !important;
            overflow: visible;
            text-overflow: inherit;
            white-space: normal;
            word-break: break-all;
            line-height: 26px !important;
        }

        .query-self {
            background-color: #0d9489 !important;
            border: #0d9489;
            color: white !important;
        }
    </style>

</head>
<body>
<!-- 顶部文件引入-->
<div class=" header">
    <header th:replace="/common/head.html"></header>
</div>
<div class="whrite">
    <!-- 灰色筛选位置 -->
    <form class="layui-form" action="">
        <div class="personnelWidth">
            <div class="currencyWidth_A">
                <div class="personnelCon">
                    <div class="sx"></div>
                    <!--	<div class="BtnEvaluate">国网阜新供电公司第一季度指标任务评价得分</div>-->
                    <!--	<div class="BtnEvaluate">国网阜新供电公司第三季度同业对标评价得分</div>-->
                    <div class="layui-inline">
                        <label class="layui-form-label">选择年月：</label>
                        <div class="layui-input-inline">
                            <input class="layui-input" id="taskMonth" name="taskMonth" placeholder="请输入查询月份"
                                   type="text">
                        </div>
                        <button class="pear-btn pear-btn-md query-self" lay-submit
                                lay-filter="result-query">
                            <i class="layui-icon layui-icon-search"></i>
                            查询
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </form>
     <!-- 管理提升 -->
    <div class="departmentBg">
        <div class="departmentContainer">
            <!-- 注释说明 -->
            <div style="padding: 0 1.5%; ">
                <div style="display:inline-block; margin-right: 2%; font-weight: bold; color: #ff7777;">注：红色背景代表分数未达到星级对应分数线</div>
                <div style="display:inline-block; margin-right: 2%; font-weight: bold; color: #ff7777;">星级达标分数线：五星(90分)  四星(85分)  三星(80分)  二星(75分)  一星(70分)</div>
            </div>
            <table id="layui-table" lay-filter="layui-table"></table>
        </div>
    </div>

</div>

<script>
    layui.use(['table', 'laydate'], function () {

        //默认查上个月数据
        var year = new Date().getFullYear()
        var month = new Date().getMonth();
        month = (month < 10 ? "0" + month : month);
        if (month == '00') {
            month = 12
            year = year - 1
        }

        //获取时间
        var laydate = layui.laydate;
        laydate.render({
            elem: '#taskMonth', //指定元素
            type: 'month',
            value: year + "-" + month
        })

        //表格
        var table = layui.table;
        var form = layui.form;
        var MODULE_PATH = rootPath + "/MonthResultController/";

        // var data = [{
        //     "id": "1",
        //     "name": "佛寺供电所",
        //     "corporation": "阜蒙县111",
        //     "year": "2023-01",
        //     "star": "五星(90)",
        //     "one": "100",
        //     "two": "100",
        //     "three": "100",
        //     "four": "100",
        //     "five": "89",
        //     "six": "100",
        //     "seven": "100",
        //     "total": "689",
        //     "totalWeight": "98.9",
        //     "prerequisite": "是",
        //     "ranking": "3",
        // }, {
        //     "id": "2",
        //     "name": "佛寺供电所",
        //     "corporation": "阜蒙县222",
        //     "year": "2023-01",
        //     "star": "四星(85)",
        //     "one": "100",
        //     "two": "100",
        //     "three": "100",
        //     "four": "100",
        //     "five": "100",
        //     "six": "100",
        //     "seven": "100",
        //     "total": "689",
        //     "totalWeight": "98.9",
        //     "prerequisite": "否",
        //     "ranking": "3",
        // }, {
        //     "id": "3",
        //     "name": "佛寺供电所",
        //     "corporation": "阜蒙县333",
        //     "year": "2023-01",
        //     "star": "三星(80)",
        //     "one": "100",
        //     "two": "100",
        //     "three": "75",
        //     "four": "100",
        //     "five": "100",
        //     "six": "100",
        //     "seven": "100",
        //     "total": "689",
        //     "totalWeight": "98.9",
        //     "prerequisite": "是",
        //     "ranking": "3",
        // }, {
        //     "id": "4",
        //     "name": "佛寺供电所",
        //     "corporation": "阜蒙县444",
        //     "year": "2023-01",
        //     "star": "二星(75)",
        //     "one": "100",
        //     "two": "100",
        //     "three": "100",
        //     "four": "70",
        //     "five": "100",
        //     "six": "100",
        //     "seven": "100",
        //     "total": "689",
        //     "totalWeight": "98.9",
        //     "prerequisite": "否",
        //     "ranking": "3",
        // }, {
        //     "id": "5",
        //     "name": "佛寺供电所",
        //     "corporation": "阜蒙县555",
        //     "year": "2023-01",
        //     "star": "一星(70)",
        //     "one": "100",
        //     "two": "100",
        //     "three": "100",
        //     "four": "100",
        //     "five": "100",
        //     "six": "100",
        //     "seven": "100",
        //     "total": "689",
        //     "totalWeight": "98.9",
        //     "prerequisite": "是",
        //     "ranking": "3",
        // },];

        table.render({
            elem: '#layui-table',
            url: MODULE_PATH + 'list4index',
            method: 'get',
            // height: 282,
            // data: data,
            // cellMinWidth: 'auto',
            page: false,
            skin: 'row,line',
            cols: [
                [ //表头
                    // {
                    //     field: 'id',
                    //     title: '编号',
                    //     align: 'center',
                    //     width: '4%',
                    // },
                    {
                        field: 'supplyName',
                        title: '供电所名称',
                        align: 'center',
                        width: '7%',
                    },
                    {
                        field: 'orgnizationName',
                        title: '所属分公司',
                        align: 'center',
                        width: '7%',
                    },
                    {
                        field: 'taskMonth',
                        title: '任务年月',
                        align: 'center',
                        width: '7%',
                    },
                    {
                        field: 'star',
                        title: '供电所星级',
                        align: 'center',
                        width: '7%',
                    },
                    {
                        field: 'yingxiaoScore',
                        title: '一、<br/>营销服务<br/>（20%）',
                        align: 'center',
                        width: '6%',
                    },
                    {
                        field: 'yunjianScore',
                        title: '二、<br/>运维抢修<br/>（20%）',
                        align: 'center',
                        width: '6%',
                    },
                    {
                        field: 'anquanScore',
                        title: '三、<br/>安全管理<br/>（15%）',
                        align: 'center',
                        width: '6%',
                    },
                    {
                        field: 'dangjianScore',
                        title: '四、<br/>党建及<br/>队伍建设<br/>（15%）',
                        align: 'center',
                        width: '8%',
                    },
                    {
                        field: 'shuzihuaScore',
                        title: '五、<br/>数字化转型<br/>（10%）',
                        align: 'center',
                        width: '7%',
                    },
                    {
                        field: 'fazhanScore',
                        title: '六、<br/>发展规划<br/>（10%）',
                        align: 'center',
                        width: '7%',
                    },
                    {
                        field: 'wuxiaoScore',
                        title: '七、<br/>“五小”建设<br/>及基础保障<br/>（10%）',
                        align: 'center',
                        width: '7%',
                    },
                    {
                        field: 'totalMark',
                        title: '总得分<br/>(末加权)',
                        align: 'center',
                        width: '6%',
                    },
                    {
                        field: 'totalScore',
                        title: '总得分<br/>(权重计算)',
                        align: 'center',
                        width: '7%',
                    },
                    {
                        field: 'isNeccessary',
                        title: '必备条件<br/>是否合格',
                        align: 'center',
                        width: '6%',
                        templet: function (res) {
                            if (res.isNeccessary == '0') {
                                return '否';
                            } else if (res.isNeccessary == '1') {
                                return '是';
                            } else if (res.isNeccessary == '2') {
                                return '结果上报中';
                            }
                        }
                    },
                    {
                        field: 'finalrank',
                        title: '排名',
                        align: 'center',
                        width: '5%',
                    }
                ]
            ],
            where: {'taskMonth': year + "-" + month},
            done: function (res, curr, count) {
                // var $data = $('div[lay-id="layui-table"]').find('.layui-table-body').find('tr').eq(0)
                //     .find('td');
                // var $head = $('div[lay-id="layui-table"]').find('.layui-table-header').find('tr').eq(
                //     0).find('th');
                // for (var i = 0; i < $data.length; i++) {
                //     var l1 = $data.eq(i).find('div').width();
                //     var l2 = $head.eq(i).find('div').width();
                //     if (l1 > l2) {
                //         $head.eq(i).find('div').width(l1);
                //     } else {
                //         $data.eq(i).find('div').width(l2);
                //     }
                // }
                // ;
                console.log(res)
                //添加背景色
                for (var i = 0; i < res.data.length; i++) {
                    var star = res.data[i].star; //星级
                    isAddBackGround(star, i, res);
                }

            }
        });

        function isAddBackGround(star, i, res) {
            var starNumber;
            if (star==5){
                starNumber = 90;
            } else if (star ==4){
                starNumber = 85;
            } else if (star ==3){
                starNumber = 80;
            } else if (star ==2){
                starNumber = 75;
            } else if (star ==1){
                starNumber = 70;
            }

            if (parseInt(res.data[i].yingxiaoScore) < starNumber) {
                var tr = $(".layui-table-body tbody tr[data-index='" + i + "']");
                var dyg = tr.children()[4];
                dyg.style.background = '#ff7777';
                dyg.style.color = '#fff';
            }
            if (parseInt(res.data[i].yunjianScore) < starNumber) {
                var tr = $(".layui-table-body tbody tr[data-index='" + i + "']");
                var dyg = tr.children()[5];
                dyg.style.background = '#ff7777';
                dyg.style.color = '#fff';
            }
            if (parseInt(res.data[i].anquanScore) < starNumber) {
                var tr = $(".layui-table-body tbody tr[data-index='" + i + "']");
                var dyg = tr.children()[6];
                dyg.style.background = '#ff7777';
                dyg.style.color = '#fff';
            }
            if (parseInt(res.data[i].dangjianScore) < starNumber) {
                var tr = $(".layui-table-body tbody tr[data-index='" + i + "']");
                var dyg = tr.children()[7];
                dyg.style.background = '#ff7777';
                dyg.style.color = '#fff';
            }
            if (parseInt(res.data[i].shuzihuaScore) < starNumber) {
                var tr = $(".layui-table-body tbody tr[data-index='" + i + "']");
                var dyg = tr.children()[8];
                dyg.style.background = '#ff7777';
                dyg.style.color = '#fff';
            }
            if (parseInt(res.data[i].fazhanScore) < starNumber) {
                var tr = $(".layui-table-body tbody tr[data-index='" + i + "']");
                var dyg = tr.children()[9];
                dyg.style.background = '#ff7777';
                dyg.style.color = '#fff';
            }
            if (parseInt(res.data[i].wuxiaoScore) < starNumber) {
                var tr = $(".layui-table-body tbody tr[data-index='" + i + "']");
                var dyg = tr.children()[10];
                dyg.style.background = '#ff7777';
                dyg.style.color = '#fff';
            }
            if (res.data[i].isNeccessary != '1') {
                var tr = $(".layui-table-body tbody tr[data-index='" + i + "']");
                var dyg = tr.children()[13];
                dyg.style.background = '#ff7777';
                dyg.style.color = '#fff';
            }
        }

        //查询按钮绑定
        form.on('submit(result-query)', function (data) {
            table.reload('layui-table', {where: data.field})
            return false;
        });
    });
</script>

<script type="text/javascript">
    $(document).ready(function () {
        $('.menu li a').each(function () {
            if ($($(this))[0].href == String(window.location))
                $(this).parent().addClass('selected');
        });

    });
</script>
</body>
</html>